const path = require("path")
const ROOT_PATH = path.dirname(__dirname) // 执行一次dirname将目录定位到docs目录
const AutoSlide = require('./utils/auto-slide')

const vuePressSlide = {
  config: function () {
    let sidebar = {}
    sidebar = createSide(sidebar, '/guide/')
    sidebar = createSide(sidebar, '/front-end/1/')
    sidebar = createSide(sidebar, '/front-end/2/')
    sidebar = createSide(sidebar, '/front-end/3/')

    sidebar = createSide(sidebar, '/algorithm/')
    sidebar = createSide(sidebar, '/source-code/vue/1/')

    sidebar = createSide(sidebar, '/browser/chrome/')
    sidebar = createSide(sidebar, '/browser/edge/')
    sidebar = createSide(sidebar, '/browser/ie/')
    sidebar = createSide(sidebar, '/browser/firefox/')
    sidebar = createSide(sidebar, '/browser/safari/')

    sidebar = createSide(sidebar, '/browser/safari/')

    return sidebar
  }
}

module.exports = vuePressSlide

function createSide(sidebar, path, collapsable = false) {
  sidebar = Object.assign(sidebar, AutoSlide.getSlide(ROOT_PATH, path, collapsable))
  return sidebar
}